#ifndef PRODUCT_H_
#define PRODUCT_H_

#include <string>
#include <sstream>
#include <vector>
#include <iostream>
#include <iomanip>

using namespace std;

struct Product
{
private:
   //constants
     

   // private data
	int prod_id;
	int cat_id;
	string prod_name;
	double prod_price;
   
public:
	//data
	
	// constructors
	Product () {}
	Product (int z, int x, string y, double a): prod_id(z), cat_id(x), prod_name(y), prod_price(a) { }

   // utility functions
	string display() const
		{
			//product display format
			stringstream sline (stringstream::in | stringstream::out);
			sline << prod_id << "\t\t" << cat_id << "\t\t"<<left<<setw(16) <<prod_name << prod_price;
			return sline.str();	
		}
	
	vector<double> prices(vector<Product>v){ //Creates a vector of just prices so it can be sorted.
		vector<double>temp;
		for(int i=0;i<v.size();++i){
			double x = v[i].prod_price;
			temp.push_back(x);
		}
		return temp;
	}
	
	void printup(vector<Product>v){ //NJG Print private members for update function
		cout << "Product ID:\tCategory ID:\tProduct:\tProduct Price:\n";
		for(int i=0;i<v.size();++i)
			cout << left<<"\t"<< v[i].prod_id<<"\t"  << v[i].cat_id <<"\t" << v[i].prod_name<<"\t" << v[i].prod_price << '\n';
		}
	
	string write()
	{
		stringstream sline (stringstream::in | stringstream::out);
		sline << prod_id << " " << cat_id << " " <<prod_name << " " << prod_price << "\n";
		return sline.str();	
	}
	
     // getter functions
   int getProdId() const {return prod_id;}
   int getCatId() const {return cat_id;}
   string getProdName() const {return prod_name;}
   double getProdPrice() const {return prod_price;}


};


#endif //PRODUCT_H_
